home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WMSGDLG.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  10.1 KB  |  273 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WMessageBox -- Wrapper for the Windows 95 Message box control.
  14.  *
  15.  *   Events:
  16.  *
  17.  *************************************************************************/
  18.  
  19. #ifndef _WMSGDLG_HPP_INCLUDED
  20. #define _WMSGDLG_HPP_INCLUDED
  21.  
  22. #ifndef _WNO_PRAGMA_PUSH
  23. #pragma pack(push,8);
  24. #pragma enum int;
  25. #endif
  26.  
  27. #ifndef _WOBJECT_HPP_INCLUDED
  28. #  include "wobject.hpp"
  29. #endif
  30.  
  31. class WMessageBox;
  32. class WWindow;
  33.  
  34. enum WMessageBoxReturn {
  35.     WMBReturnOk         = 1,
  36.     WMBReturnCancel     = 2,
  37.     WMBReturnAbort      = 3,
  38.     WMBReturnRetry      = 4,
  39.     WMBReturnIgnore     = 5,
  40.     WMBReturnYes        = 6,
  41.     WMBReturnNo         = 7,
  42.     WMBReturnClose      = 8,
  43.     WMBReturnHelp       = 9,
  44.     WMBReturnUnknown    = 10,
  45. };
  46.  
  47. typedef WStyle                  WMsgBStyle;
  48.  
  49. //
  50. // MessageBox styles
  51. //
  52.  
  53. #define WMsgBSOk                       ((WMsgBStyle)0x00000000L)
  54. #define WMsgBSOkCancel                 ((WMsgBStyle)0x00000001L)
  55. #define WMsgBSAbortRetryIgnore         ((WMsgBStyle)0x00000002L)
  56. #define WMsgBSYesNoCancel              ((WMsgBStyle)0x00000003L)
  57. #define WMsgBSYesNo                    ((WMsgBStyle)0x00000004L)
  58. #define WMsgBSRetryCancel              ((WMsgBStyle)0x00000005L)
  59.  
  60. #define WMsgBSIconError                ((WMsgBStyle)0x00000010L)
  61. #define WMsgBSIconQuestion             ((WMsgBStyle)0x00000020L)
  62. #define WMsgBSIconWarning              ((WMsgBStyle)0x00000030L)
  63. #define WMsgBSIconInformation          ((WMsgBStyle)0x00000040L)
  64. #define WMsgBSIconHand                 WMsgBSIconError
  65. #define WMsgBSIconStop                 WMsgBSIconError
  66. #define WMsgBSIconExclamation          WMsgBSIconWarning
  67. #define WMsgBSIconAsterisk             WMsgBSIconInformation
  68.  
  69. #define WMsgBSDefButton1               ((WMsgBStyle)0x00000000L)
  70. #define WMsgBSDefButton2               ((WMsgBStyle)0x00000100L)
  71. #define WMsgBSDefButton3               ((WMsgBStyle)0x00000200L)
  72. #define WMsgBSDefButton4               ((WMsgBStyle)0x00000300L)
  73.  
  74. #define WMsgBSApplModal                ((WMsgBStyle)0x00000000L)
  75. #define WMsgBSApplicationModal         ((WMsgBStyle)0x00000000L)
  76. #define WMsgBSSystemModal              ((WMsgBStyle)0x00001000L)
  77. #define WMsgBSTaskModal                ((WMsgBStyle)0x00002000L)
  78. #define WMsgBSHelp                     ((WMsgBStyle)0x00004000L)
  79.  
  80. #define WMsgBSLeft                     ((WMsgBStyle)0x00000000L)
  81. #define WMsgBSRight                    ((WMsgBStyle)0x00080000L)
  82.  
  83. #define WMsgBSRtlReading               ((WMsgBStyle)0x00100000L)
  84.  
  85. #define WMsgBSNoFocus                  ((WMsgBStyle)0x00008000L)
  86. #define WMsgBSSetForeground            ((WMsgBStyle)0x00010000L)
  87. #define WMsgBSDefaultDesktopOnly       ((WMsgBStyle)0x00020000L)
  88. #define WMsgBSServiceNotification      ((WMsgBStyle)0x00040000L)
  89.  
  90. #define WMsgBSTypeMask                 ((WMsgBStyle)0x0000000FL)
  91. #define WMsgBSUserIcon                 ((WMsgBStyle)0x00000080L)
  92. #define WMsgBSIconMask                 ((WMsgBStyle)0x000000F0L)
  93. #define WMsgBSDefMask                  ((WMsgBStyle)0x00000F00L)
  94. #define WMsgBSModeMask                 ((WMsgBStyle)0x00003000L)
  95. #define WMsgBSMiscMask                 ((WMsgBStyle)0x0000C000L)
  96.  
  97. enum WMessageBoxButton {
  98.     WMBButtonOk = WMsgBSOk,
  99.     WMBButtonOkCancel = WMsgBSOkCancel,
  100.     WMBButtonAbortRetryIgnore = WMsgBSAbortRetryIgnore,
  101.     WMBButtonYesNoCancel = WMsgBSYesNoCancel,
  102.     WMBButtonYesNo = WMsgBSYesNo,
  103.     WMBButtonRetryCancel = WMsgBSRetryCancel,
  104. };
  105.  
  106. enum WMessageBoxLevel {
  107.     WMBLevelPlain = 0,
  108.     WMBLevelInfo = WMsgBSIconInformation,
  109.     WMBLevelQuestion = WMsgBSIconQuestion,
  110.     WMBLevelReminder = WMsgBSIconWarning,
  111.     WMBLevelWarning = WMsgBSIconWarning,
  112.     WMBLevelError = WMsgBSIconError,
  113. };
  114.     
  115. enum WMessageBoxDefaultButton {
  116.     WMBDefault1 = WMsgBSDefButton1,
  117.     WMBDefault2 = WMsgBSDefButton2,
  118.     WMBDefault3 = WMsgBSDefButton3,
  119.     WMBDefault4 = WMsgBSDefButton4,
  120. };
  121.  
  122. enum WMessageBoxAttribute {
  123.     WMBAttributeNormal = WMsgBSTaskModal,
  124.     WMBAttributeSystemModal = WMsgBSSystemModal,
  125.     WMBAttributeNoFocus = WMsgBSNoFocus,
  126.     WMBAttributeTaskModal = WMsgBSTaskModal,
  127.     WMBAttributeApplModal = WMsgBSApplModal,
  128.     WMBAttributeApplicationModal = WMsgBSApplicationModal,
  129. };
  130.  
  131. class WCMCLASS WMessageBox : public WObject {
  132.     WDeclareSubclass( WMessageBox, WObject );
  133.     
  134.     public:
  135.     
  136.         /*******************************************************
  137.          * Constructors and Destructors
  138.          *******************************************************/
  139.         
  140.         WMessageBox();
  141.     
  142.         ~WMessageBox();
  143.     
  144.         /*******************************************************
  145.          * Properties
  146.          *******************************************************/
  147.  
  148.         // Attribute
  149.  
  150.         WMessageBoxAttribute GetAttribute() const;
  151.         WBool SetAttribute( WMessageBoxAttribute attribute );
  152.  
  153.         // Button
  154.  
  155.         WMessageBoxButton GetButton() const;
  156.         WBool SetButton( WMessageBoxButton button );
  157.  
  158.         // Caption
  159.  
  160.         WString GetCaption() const;
  161.         WBool SetCaption( const WString & caption );
  162.  
  163.         // DefaultButton
  164.  
  165.         WMessageBoxDefaultButton GetDefaultButton() const;
  166.         WBool SetDefaultButton( WMessageBoxDefaultButton defaultButton );
  167.  
  168.         // Level
  169.  
  170.         WMessageBoxLevel GetLevel() const;
  171.         WBool SetLevel( WMessageBoxLevel level );
  172.  
  173.         // Parent
  174.  
  175.         WWindow * GetParent() const;
  176.         WBool SetParent( WWindow * parent );
  177.  
  178.         // Style
  179.  
  180.         WMsgBStyle GetStyle() const;
  181.         WBool SetStyle( WMsgBStyle style );
  182.  
  183.         // Text
  184.  
  185.         WString GetText() const;
  186.         WBool SetText( const WString & text );
  187.  
  188.         /*******************************************************
  189.          * Methods
  190.          *******************************************************/
  191.  
  192.         // ChangeStyle
  193.  
  194.         WBool ChangeStyle( WMsgBStyle style, WBool on );
  195.  
  196.         // Prompt
  197.  
  198.         WMessageBoxReturn Prompt();
  199.  
  200.         // Messagef
  201.  
  202.         static WMessageBoxReturn Messagef( WWindow * parent,
  203.                                            WMsgBStyle style,
  204.                                            const WChar * caption,
  205.                                            const WChar * format, ... );
  206.         static WMessageBoxReturn Messagef( WWindow * parent,
  207.                                            WMessageBoxLevel level,
  208.                                            WMessageBoxButton button,
  209.                                            const WChar * caption,
  210.                                            const WChar * format, ... );
  211.         static WMessageBoxReturn MessageFormat( WWindow * parent,
  212.                                            WMsgBStyle style,
  213.                                            const WChar * caption,
  214.                                            const WChar * format, ... );
  215.         static WMessageBoxReturn MessageFormat( WWindow * parent,
  216.                                            WMessageBoxLevel level,
  217.                                            WMessageBoxButton button,
  218.                                            const WChar * caption,
  219.                                            const WChar * format, ... );
  220.  
  221.         // Message
  222.  
  223.         static WMessageBoxReturn Message( WWindow * parent, WMsgBStyle style,
  224.                                           const WChar * caption,
  225.                                           const WChar * text );
  226.         static WMessageBoxReturn Message( WWindow * parent,
  227.                                           WMessageBoxLevel level,
  228.                                           WMessageBoxButton button,
  229.                                           const WChar * caption,
  230.                                           const WChar * text,
  231.                                           WMessageBoxDefaultButton
  232.                                             defaultButton = WMBDefault1,
  233.                                           WMessageBoxAttribute
  234.                                             attribute = WMBAttributeNormal );
  235.  
  236.         // Info
  237.  
  238.         static void Info( WWindow * parent, const WChar * caption,
  239.                           const WChar * format, ... );
  240.     
  241.         /*******************************************************
  242.          * Others
  243.          *******************************************************/
  244.  
  245.     private:
  246.     
  247.         static WMessageBoxReturn DoMessage( WWindow * parent,
  248.                                             WMsgBStyle style,
  249.                                             const WChar * text,
  250.                                             const WChar * caption );
  251.         static WMessageBoxReturn DoMessage( WWindow * parent,
  252.                                             WMessageBoxLevel level,
  253.                                             WMessageBoxButton button,
  254.                                             const WChar * text,
  255.                                             const WChar * caption,
  256.                                             WMessageBoxDefaultButton
  257.                                               defaultButton = WMBDefault1,
  258.                                             WMessageBoxAttribute
  259.                                               attribute = WMBAttributeNormal );
  260.  
  261.         WString         _caption;
  262.         WString         _text;
  263.         WMsgBStyle      _style;
  264.         WWindow *       _parent;
  265. };
  266.  
  267. #ifndef _WNO_PRAGMA_PUSH
  268. #pragma enum pop;
  269. #pragma pack(pop);
  270. #endif
  271.  
  272. #endif // _WMSGDLG_HPP_INCLUDED
  273.